// x + 2 * y^2 = z
pub fn goldbach_conjecture() -> u64 {
    let mut count = 0;
    let mut sum = 0;
    for z in (9..u64::MAX).step_by(2) {
        if count == 2 { break }
        if !is_prime(z) {
            let mut finded = false; // any odd and not prime
            for x in (1..z).step_by(2) { // 1 <= x < z
                if finded { break }
                if is_prime(x) { // get prime x
                    let limit_y = (((z - x) / 2) as f64).sqrt() as u64; // reduce y limit
                    for y in 1..=limit_y {
                        if finded { break }
                        if z == x + 2 * y * y {
                            finded = true;
                        }
                    }
                }
            }
            if !finded {
                count += 1;
                sum += z;
            }
        }
    }
    sum
}

fn is_prime (num: u64) -> bool {
    if num % 6 != 1 && num % 6 != 5 {
        return false
    }
    let sqrt_num = (num as f64).sqrt() as u64;
    for i in (5..=sqrt_num).step_by(6) {
        if num % i == 0 || num % (i + 2) == 0 {
            return false
        }
    }
    true
}